added some development tools
[windows-sources.git] / developer / Samples / NET 4.6 / Famliy_Tree_DSL / DslPackage / Backup / GeneratedCode / DocView.cs
blob21781a0554d725ff46c0f988e6ffcb81fd0dfc14
1 //------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by a tool.
4 //
5 // Changes to this file may cause incorrect behavior and will be lost if
6 // the code is regenerated.
7 // </auto-generated>
8 //------------------------------------------------------------------------------
10 using DslModeling = global::Microsoft.VisualStudio.Modeling;
11 using DslDiagrams = global::Microsoft.VisualStudio.Modeling.Diagrams;
12 using DslShell = global::Microsoft.VisualStudio.Modeling.Shell;
14 namespace Fabrikam.Dsl.TestValidation
16 /// <summary>
17 /// Double-derived class to allow easier code customization.
18 /// </summary>
19 internal partial class TestValidationDocView : TestValidationDocViewBase
21 /// <summary>
22 /// Constructs a new TestValidationDocView.
23 /// </summary>
24 public TestValidationDocView(DslShell::ModelingDocData docData, global::System.IServiceProvider serviceProvider)
25 : base(docData, serviceProvider)
30 /// <summary>
31 /// Class that hosts the diagram surface in the Visual Studio document area.
32 /// </summary>
33 internal abstract class TestValidationDocViewBase : DslShell::SingleDiagramDocView
35 /// <summary>
36 /// Constructs a new TestValidationDocView.
37 /// </summary>
38 protected TestValidationDocViewBase(DslShell::ModelingDocData docData, global::System.IServiceProvider serviceProvider) : base(docData, serviceProvider)
42 /// <summary>
43 /// Called to initialize the view after the corresponding document has been loaded.
44 /// </summary>
45 protected override bool LoadView()
47 base.LoadView();
49 global::System.Diagnostics.Debug.Assert(this.DocData.RootElement!=null);
50 if (this.DocData.RootElement == null)
52 return false;
55 // The diagram should exist in the diagram partition by now, just need to find it and connect it to this view.
56 TestValidationDocDataBase docData = this.DocData as TestValidationDocDataBase;
57 global::System.Diagnostics.Debug.Assert(docData != null, "DocData for TestValidationDocViewBase should be an TestValidationDocDataBase!");
58 DslModeling::Partition diagramPartition = docData.GetDiagramPartition();
59 if (diagramPartition != null)
61 global::System.Collections.ObjectModel.ReadOnlyCollection<global::Fabrikam.Dsl.TestValidation.TestValidationDiagram> diagrams = docData.GetDiagramPartition().ElementDirectory.FindElements<global::Fabrikam.Dsl.TestValidation.TestValidationDiagram>();
62 if (diagrams.Count > 0)
64 global::System.Diagnostics.Debug.Assert(diagrams.Count == 1, "Found more than one diagram, using the first one found.");
65 this.Diagram = (DslDiagrams::Diagram)diagrams[0];
67 else
69 return false;
72 else
74 return false;
77 return true;
80 /// <summary>
81 /// Name of the toolbox tab that should be displayed when the diagram is opened.
82 /// </summary>
83 protected override string DefaultToolboxTabName
85 get
87 return global::Fabrikam.Dsl.TestValidation.TestValidationToolboxHelper.DefaultToolboxTabName;
91 /// <summary>
92 /// Returns the toolbox items count in the default tool box tab.
93 /// </summary>
94 protected override int DefaultToolboxTabToolboxItemsCount
96 get
98 return global::Fabrikam.Dsl.TestValidation.TestValidationToolboxHelper.DefaultToolboxTabToolboxItemsCount;
103 /// <summary>
104 /// Context menu displayed when the user right-clicks on the design surface.
105 /// </summary>
106 protected override global::System.ComponentModel.Design.CommandID ContextMenuId
110 return Constants.TestValidationDiagramMenu;
114 /// <summary>
115 /// Called when selection changes in this window.
116 /// </summary>
117 /// <remarks>
118 /// Overriden to update the F1 help keyword for the selection.
119 /// </remarks>
120 /// <param name="e"></param>
121 protected override void OnSelectionChanged(global::System.EventArgs e)
123 base.OnSelectionChanged(e);
125 if(global::Fabrikam.Dsl.TestValidation.TestValidationHelpKeywordHelper.Instance != null)
127 DslModeling::ModelElement selectedElement = this.PrimarySelection as DslModeling::ModelElement;
128 if(selectedElement != null)
130 string f1Keyword = global::Fabrikam.Dsl.TestValidation.TestValidationHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);
132 // If this is a presentation element, check the underlying model element for a help keyword
133 DslDiagrams::PresentationElement presentationElement = this.PrimarySelection as DslDiagrams::PresentationElement;
134 if(presentationElement != null)
136 selectedElement = presentationElement.ModelElement;
137 if(selectedElement != null)
139 string modelElementKeyword = global::Fabrikam.Dsl.TestValidation.TestValidationHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);
140 if(string.IsNullOrEmpty(f1Keyword))
142 // Presentation element does not have an F1 keyword, so push the keyword from the model element as an F1 keyword.
143 f1Keyword = modelElementKeyword;
145 else if (!string.IsNullOrEmpty(modelElementKeyword) && this.SelectionHelpService != null)
147 // Presentation element has an F1 keyword, so push model element keyword as a general dynamic help keyword (non-F1).
148 this.SelectionHelpService.AddContextAttribute(string.Empty, modelElementKeyword, global::System.ComponentModel.Design.HelpKeywordType.GeneralKeyword);
153 if(!string.IsNullOrEmpty(f1Keyword) && this.SelectionHelpService != null)
155 this.SelectionHelpService.AddContextAttribute(string.Empty, f1Keyword, global::System.ComponentModel.Design.HelpKeywordType.F1Keyword);